#ifndef WXCCONNECTOR_H
#define WXCCONNECTOR_H

#include <wx/event.h>
#include <wx/process.h>
#include "wxcLib/clSocketBase.h"
#include "wxcLib/wxcNetworkCommand.h"


class wxcNetworkReplyThread;
class wxcConnector : public wxEvtHandler
{
    clSocketBase::Ptr_t     m_socket;
    wxProcess*              m_wxcrafterProcess;
    wxString                m_wxcrafterExecCommand;
    wxcNetworkReplyThread*  m_networkThread;
    
protected:
    DECLARE_EVENT_TABLE()
    void OnProcessTerminated(wxProcessEvent& event);
    void OnFilesGenerated(wxCommandEvent& event);
    
private:
    void DoLaunchAndConnect() throw (clSocketException);
    
public:
    wxcConnector();
    virtual ~wxcConnector();
    
    
    bool IsConnected() const;
    
    void Shutdown();
    
    
    void LaunchAndConnect(const wxString &wxcPath) throw (clSocketException);

    
    void SendCommand(const wxcNetworkCommand& command) throw (clSocketException);
    
    
    void LoadFile( const wxFileName& filename ) throw (clSocketException);
    
    
    void GenerateCode( const wxFileName& wxcpFileName) throw (clSocketException);
    
    
    void NewForm(const wxFileName& wxcpFile, wxCrafter::eCommandType formType);
};

#endif // WXCCONNECTOR_H
